package com.terry.test3;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @author 小八
 * @date 2023年02月14日10:54
 */
public class Title39 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextLine()){
            String[] splits = in.nextLine().split(" ");
            Arrays.sort(splits,(a,b)->{
                int index1 = 0;
                int index2 = 0;
                while(index1<a.length() && index2<b.length()){
                    if(a.charAt(index1) == b.charAt(index2)){
                        index1++;
                        index2++;
                        continue;
                    }else{
                        return b.charAt(index2) - a.charAt(index1);
                    }
                }
                if(index1<a.length()){
                    return   b.charAt(0) - a.charAt(index1) ;
                }else{
                    return b.charAt(index2)  -  a.charAt(0) ;
                }
            });
            System.out.println(splits);
        }
    }
}
//1 20 23 4 8
//1 201 20 9 8
//1 203 20 9 8